//*********************************************************
//
//    Copyright (c) Microsoft. All rights reserved.
//    This code is licensed under the Apache License, Version 2.0.
//    THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
//    ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
//    IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
//    PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Microsoft.Research.DataLayer
{
    /// <summary>
    /// Wraps a relation to allow migration to another store, using the same interfaces
    /// </summary>
    public class ExtraRelationDataBridge : IObject, IExtraRelationData
    {
        IObject parent;
        IObject child;
        Connection.Storage type;
        IExtraRelationData bridge;

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="type"></param>
        /// <param name="parent"></param>
        /// <param name="child"></param>
        /// <param name="bridge"></param>
        public ExtraRelationDataBridge(Connection.Storage type, IObject parent, IObject child, IExtraRelationData bridge)
        {
            this.type = type;
            this.parent = parent;
            this.child = child;
            this.bridge = bridge;
        }

        #region IObject Members

        /// <summary>
        /// ID of object
        /// </summary>
        public Guid ID
        {
            get { return Guid.Empty; }
        }

        /// <summary>
        /// Type of object
        /// </summary>
        public Connection.Storage ObjType
        {
            get { return type; }
        }

        /// <summary>
        /// NOT SUPPORTED IN BRIDGE MODE
        /// </summary>
        /// <param name="targetConnection"></param>
        /// <returns></returns>
        public IObject CopyTo(Connection targetConnection)
        {
            throw new NotSupportedException();
        }

        /// <summary>
        /// NOT SUPPORTED IN BRIDGE MODE
        /// </summary>
        public void Refresh()
        {
            throw new NotSupportedException();
        }

        /// <summary>
        /// NOT SUPPORTED IN BRIDGE MODE
        /// </summary>
        public void Save()
        {
            throw new NotSupportedException();
        }

        /// <summary>
        /// NOT SUPPORTED IN BRIDGE MODE
        /// </summary>
        public void Delete()
        {
            throw new NotSupportedException();
        }

        #endregion

        #region IExtraRelationData Members

        /// <summary>
        /// ID of parent object
        /// </summary>
        public Guid ParentID
        {
            get { return parent.ID; }
        }

        /// <summary>
        /// ID of child object
        /// </summary>
        public Guid ChildID
        {
            get { return child.ID; }
        }

        /// <summary>
        /// Parent object
        /// </summary>
        public IObject ParentObj
        {
            get { return parent; }
        }

        /// <summary>
        /// Child object
        /// </summary>
        public IObject ChildObj
        {
            get { return child; }
        }

        /// <summary>
        /// Child object type
        /// </summary>
        public Connection.Storage ChildType
        {
            get { return child.ObjType; }
        }

        /// <summary>
        /// Relationship data held by child object
        /// </summary>
        public List<Parameter> ExtraData
        {
            get { return bridge.ExtraData; }
        }

        /// <summary>
        /// NOT SUPPORTED IN BRIDGE MODE
        /// </summary>
        /// <param name="target"></param>
        /// <param name="targetParent"></param>
        /// <param name="targetChild"></param>
        /// <returns></returns>
        public IObject CopyTo(Connection target, IObject targetParent, IObject targetChild)
        {
            throw new NotSupportedException();
        }

        #endregion
    }
}
